export default {
  methods: {
    getBroswer() {
      let userAgent = navigator.userAgent
      let BrowserStr = 'Unknown'
      if (userAgent.match(/iPhone/i)) {
        BrowserStr = 'iphone'
      } else if (userAgent.match(/Android/i)) {
        BrowserStr = 'Android'
      } else if (/Chrome/.test(userAgent)) {
        BrowserStr = 'Chrome'
      } else if (/Firefox/.test(userAgent)) {
        BrowserStr = 'Firefox'
      } else if (/Safari/.test(userAgent)) {
        BrowserStr = 'Safari'
      } else if (/Edg/.test(userAgent)) {
        BrowserStr = 'Edge'
      } else if (/MSIE|Trident/.test(userAgent)) {
        BrowserStr = 'IE'
      } else if (/Opera/.test(userAgent) || /OPR/.test(userAgent)) {
        BrowserStr = 'Opera'
      }
      return BrowserStr
    },
    getCurPageName(pageFrom) {
      let routeName = pageFrom
        ? pageFrom.replace('lang-', '')
        : this.$route.name.replace('lang-', '')
      let resStr = ''
      switch (routeName) {
        case 'index':
          resStr = '首页'
          break
        case 'new':
          resStr = '最新AI'
          break
        case 'most-saved':
          resStr = '最多保存'
          break
        case 'most-used':
          resStr = '最多人使用'
          break
        case 'browser-extension':
          resStr = '浏览器插件'
          break
        case 'apps':
          resStr = 'Apps页'
          break
        case 'search-handle':
          resStr = '搜索结果页'
          break
        case 'category':
          resStr = '分类页'
          break
        case 'category-handle':
          resStr = '分类详情页'
          break
        case 'category-attribute-handle':
          resStr = '分类属性页'
          break
        case 'month-handle':
          resStr = '月份页'
          break
        case 'tool-handle':
          resStr = '工具详情页'
          break
        case 'Best-trending-AI-Tools-month':
          resStr = '月榜'
          break
        case 'Best-AI-Tools-Category-category':
          resStr = '分类榜'
          break
        case 'Best-AI-Tools-region-region':
          resStr = '地区榜'
          break
        case 'Best-AI-Tools-Source-source':
          resStr = '渠道榜'
          break
        case 'Best-AI-Tools-revenue':
          resStr = '收入榜'
          break
        case 'tag-handle':
          resStr = '标签详情页'
          break
        case 'compare-handle':
          resStr = 'VS页'
          break
        case 'alternative-handle':
          resStr = '替代品页'
          break
        case 'review-handle':
          resStr = 'review页'
          break
        case 'top-ai-tools':
          resStr = 'top-ai-tools页'
          break

        case 'top-ai-tools-page-page':
          resStr = 'top-ai-tools页'
          break
        case 'top-ai-tools-handle':
          resStr = 'top-ai-tools页'
          break
        case 'ai-for-capabilities':
          resStr = 'ai-for-capabilities页'
          break
        case 'ai-for-jobs':
          resStr = 'ai-for-jobs页'
          break
        case 'favorites':
          resStr = 'favorites页'
          break
        case 'free':
          resStr = 'free页'
          break
        case 'gpts':
          resStr = 'gpts页'
          break
        case 'gpts-handle':
          resStr = 'gpts-handle页'
          break
        case 'gpts-favorites':
          resStr = 'gpts-favorites页'
          break
        case 'payment':
          resStr = 'payment页'
          break
        case 'privacy-policy':
          resStr = 'privacy-policy页'
          break
        case 'submit':
          resStr = 'submit页'
          break
        case 'success':
          resStr = 'success页'
          break
        case 'user':
          resStr = 'user页'
          break
        case 'promote':
          resStr = 'promote页'
          break
        case 'advertise':
          resStr = 'advertise页'
          break
        default:
          resStr = routeName
      }
      return resStr
    },
    getDeviceType() {
      if (
        /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
          navigator.userAgent
        )
      ) {
        return 'phone'
      } else {
        return 'web'
      }
    },
  },
}
